Imports Microsoft.VisualBasic
Imports System
Imports System.Collections
Imports System.ComponentModel
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Data
Imports System.Windows.Forms
Imports System.Windows.Forms.Design
Imports System.ComponentModel.Design
Imports System.Drawing.Design


Namespace Phoenix.Tools
	Public Class WizardPageBase : Inherits System.Windows.Forms.UserControl
#Region "Class Members"
        Private components As System.ComponentModel.Container = Nothing ' container
        Private m_parent As WizardForm = Nothing ' page parent

        Private m_iIndex As Integer = -1 ' Order identifier of page
        Private m_strTitle As String ' Page Title
        Private m_strDescription As String ' Page Desription
        Private m_imgHeader As Image ' Page Image
        Private m_bFireEvents As Boolean = True ' Identifier of QUIET mode
        Private m_bFinishPage As Boolean ' Is Wizard Page a Finish Page
        Private m_bHelpExists As Boolean ' Does page has Help or Not
        Private m_bIsWelcome As Boolean ' Is Page Use Full Wizard Panel or not

        Private m_imgList As ImageList
        Private m_iImageIndex As Integer = -1
#End Region

#Region "Class Properties"
        <Browsable(True), DefaultValue(-1), Description("Order position of wizard page in Wizard Control"), Category("Wizard Page")> _
        Public Property Index() As Integer
            Get
                Return m_iIndex
            End Get
            Set(ByVal Value As Integer)
                If Value <> m_iIndex Then
                    m_iIndex = Value
                    OnIndexChanged()
                    OnChanged()
                End If
            End Set
        End Property

        <Browsable(False), Description("Gets/Sets Page Parent control")> _
        Public Property WizardPageParent() As WizardForm
            Get
                Return m_parent
            End Get
            Set(ByVal Value As WizardForm)
                If Not Value Is m_parent Then
                    m_parent = Value
                    OnWizardPageParentChanged()
                End If
            End Set
        End Property

        <Browsable(True), Category("Wizard Page"), Description("Gets/Sets wizard page Title Text")> _
        Public Property Title() As String
            Get
                Return m_strTitle
            End Get
            Set(ByVal Value As String)
                If Value <> m_strTitle Then
                    m_strTitle = Value
                    OnTitleChanged()
                    OnChanged()
                End If
            End Set
        End Property

        <Browsable(True), Category("Wizard Page"), Description("Gets/Sets wizard page description Text")> _
        Public Property Description() As String
            Get
                Return m_strDescription
            End Get
            Set(ByVal Value As String)
                If Value <> m_strDescription Then
                    m_strDescription = Value
                    OnDescriptionChanged()
                    OnChanged()
                End If
            End Set
        End Property

        <Browsable(True), Category("Wizard Page"), Description("Gets/Sets wizard page special Image")> _
        Public Property HeaderImage() As Image
            Get
                Return m_imgHeader
            End Get
            Set(ByVal Value As Image)
                If Not Value Is m_imgHeader Then
                    m_imgHeader = Value
                    OnHeaderImageChanged()
                    OnChanged()
                End If
            End Set
        End Property

        <Browsable(True), Category("Wizard Page"), Description("Gets/Sets wizard page special ImageList")> _
        Public Property ImageList() As ImageList
            Get
                Return m_imgList
            End Get
            Set(ByVal Value As ImageList)
                If Not Value Is m_imgList Then
                    m_imgList = Value
                    OnImageListChanged()
                    OnChanged()
                End If
            End Set
        End Property

        <Browsable(True), Category("Wizard Page"), Description("Gets/Sets Image from ImageList which will be used as a HeaderImage"), DefaultValue(-1), Editor("System.Windows.Forms.Design.ImageIndexEditor, System.Design, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", GetType(System.Drawing.Design.UITypeEditor)), TypeConverter("System.Windows.Forms.ImageIndexConverter")> _
        Public Property ImageIndex() As Integer
            Get
                Return m_iImageIndex
            End Get
            Set(ByVal Value As Integer)
                If Value <> m_iImageIndex Then
                    m_iImageIndex = Value
                    OnImageIndexChanged()
                    OnChanged()
                End If
            End Set
        End Property

        <Browsable(False), DefaultValue(False)> _
        Public Property QuietMode() As Boolean
            Get
                Return Not m_bFireEvents
            End Get
            Set(ByVal Value As Boolean)
                If Value <> m_bFireEvents Then
                    m_bFireEvents = Not Value
                    OnQuietModeChanged()
                End If
            End Set
        End Property

        <Browsable(True), Category("Wizard Page"), Description("Gets/Sets Is wizard page last in Wizard Control"), DefaultValue(False)> _
        Public Property FinishPage() As Boolean
            Get
                Return m_bFinishPage
            End Get
            Set(ByVal Value As Boolean)
                If Value <> m_bFinishPage Then
                    m_bFinishPage = Value
                    OnFinishPageChanged()
                    OnChanged()
                End If
            End Set
        End Property

        <Browsable(True), Category("Wizard Page"), Description("Gets/Sets Is wizard page Has help Page"), DefaultValue(False)> _
        Public Property HelpAvailable() As Boolean
            Get
                Return m_bHelpExists
            End Get
            Set(ByVal Value As Boolean)
                If Value <> m_bHelpExists Then
                    m_bHelpExists = Value
                    OnHelpAvailableChangd()
                    OnChanged()
                End If
            End Set
        End Property

        <Browsable(True), Category("Wizard Page"), Description("Gets/Sets Is wizard page is a Welcome Page"), DefaultValue(False)> _
        Public Property WelcomePage() As Boolean
            Get
                Return m_bIsWelcome
            End Get
            Set(ByVal Value As Boolean)
                If Value <> m_bIsWelcome Then
                    m_bIsWelcome = Value
                    OnWelcomePageChanged()
                    OnChanged()
                End If
            End Set
        End Property

        Protected Overrides ReadOnly Property DefaultSize() As System.Drawing.Size
            Get
                Return New Size(498, 328)
            End Get
        End Property
#End Region

#Region "Class Events"
        <Category("Wizard Page")> _
        Public Event Changed As EventHandler

        <Category("Wizard Page")> _
        Public Event NextEvent As WizardForm.WizardNextEventHandler
#End Region

#Region "Class Initialze/Finilize methods"
        ''' <summary>
        ''' Default constractor
        ''' </summary>
        Public Sub New()
            InitializeComponent()

            MyBase.Dock = DockStyle.Fill
        End Sub

        ''' <summary>
        ''' Free custom resources
        ''' </summary>
        ''' <param name="disposing">if TRUE then free resources</param>
        Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
            If disposing AndAlso Not components Is Nothing Then
                components.Dispose()
            End If

            MyBase.Dispose(disposing)
        End Sub
#End Region

#Region "Component Designer generated code"
        ''' <summary>
        ''' Initialize Control
        ''' </summary>
        Private Sub InitializeComponent()
            ' 
            ' WizardPageBase
            ' 
            Me.Name = "WizardPage"
            Me.Size = New System.Drawing.Size(424, 248)

        End Sub
#End Region

#Region "Class overrides for inheritors"
        Protected Friend Overridable Sub OnPageShown()
        End Sub
        Protected Overridable Sub OnIndexChanged()
        End Sub
        Protected Overridable Sub OnWizardPageParentChanged()
        End Sub
        Protected Overridable Sub OnTitleChanged()
        End Sub
        Protected Overridable Sub OnDescriptionChanged()
        End Sub
        Protected Overridable Sub OnHeaderImageChanged()
        End Sub
        Protected Overridable Sub OnImageListChanged()
        End Sub
        Protected Overridable Sub OnImageIndexChanged()
        End Sub
        Protected Overridable Sub OnQuietModeChanged()
        End Sub
        Protected Overridable Sub OnFinishPageChanged()
        End Sub
        Protected Overridable Sub OnHelpAvailableChangd()
        End Sub
        Protected Overridable Sub OnWelcomePageChanged()
        End Sub
#End Region

#Region "Class Overrides"
        ''' <summary>
        ''' Function Raise "Changed" event when property of class changed
        ''' </summary>
        Protected Overridable Sub OnChanged()
            If Not ChangedEvent Is Nothing AndAlso m_bFireEvents = True Then
                RaiseEvent Changed(Me, EventArgs.Empty)
            End If
        End Sub

        Protected Friend Overridable Sub OnNextPressed()
            Dim e As WizardForm.EventNextArgs = New WizardForm.EventNextArgs(Me)

            RaiseEvent NextEvent(Me, e)
        End Sub

#End Region
    End Class
End Namespace
